<?php

use Illuminate\Http\Request;
use Illuminate\Support\Facades\Route;

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/

Route::group(['namespace' => 'Member'], function() {

    // 无需用户授权路由
    
    Route::group(['prefix' => 'wechat'], function(){
        // get用户配置公众号域名 post用于接收微信推送事件
        Route::get('/event','WechatController@event');
        Route::post('/event','WechatController@event');

        Route::get('/oauth','WechatController@getOauthUrl');
        Route::post('/login','WechatController@wxLogin');
        Route::get('/token','WechatController@getAccessToken');
    });

    Route::group(['prefix' => 'user'], function(){
        Route::post('/login/code','UserController@codeLogin');
        Route::post('/login/password','UserController@passwordLogin');
        Route::post('/bind','UserController@bind');
        Route::post('/send_code','UserController@sendCode');
        Route::get('/parent','UserController@getParentInfo');
        Route::get('/store/info','UserController@getStoreInfo');
        Route::get('/mean','UserController@getMeanList');
    });
    Route::group(['prefix' => 'setting'], function(){
        Route::post('/password','UserController@setPassword');
    });
    Route::group(['prefix' => 'pay'], function(){
        Route::post('callback','PayController@wxCallback');
        Route::post('yopwxcallback','PayController@yopWxCallback');//易宝聚合支付-微信支付 异步回调
        Route::post('check_code','PayController@checkCode');//易宝聚合支付-微信支付 异步回调
    });

    // 需授权路由
    Route::middleware(['auth.member'])->group(function(){
        Route::group(['prefix' => 'wx_sdk'], function(){
            Route::get('/init','WechatController@initSdk');
        });

        Route::group(['prefix' => 'setting'], function(){
            Route::post('/nickname','UserController@setNickname');
            Route::post('/name','UserController@setName');
            Route::post('/phone','UserController@setPhone');
            Route::post('/wechat','UserController@setWechat');
            Route::post('/pwd_by_origin','UserController@setPasswordByOrigin'); // 通过原密码修改新密码
            Route::post('/avatar','UserController@setAvatar'); // 设置头像
        });

        Route::group(['prefix' => 'user'], function(){
            Route::get('/member/info','UserController@getUserInfo');
            Route::get('/fans/list','UserController@getFansList');
            Route::get('/fans/detail','UserController@getFansDetail');

            Route::get('/fans/manage','UserController@fansManage');  // 个人中心粉丝管理
            Route::get('/recommend','UserController@recommend');  // 个人中心粉丝管理

            Route::get('/is_pay_password','UserController@isPayPassword');// 判断支付密码是否设置 , 返回 0 / 1
            Route::post('/set_pay_password','UserController@setPayPassword');// 设置支付密码 返回 0/1
        });

        Route::group(['prefix' => 'good'], function(){
            Route::get('/type','GoodController@getType');
            Route::get('/mall','GoodController@getMall');
            Route::get('/hot','GoodController@getHot');
            Route::get('/detail','GoodController@getDetail');
        });

        Route::group(['prefix' => 'store'], function(){
            Route::post('/cart','StoreController@getUserCart');
        });
        Route::group(['prefix' => 'order'], function(){
            Route::post('/confirm_order','OrderController@confirmOrder');// 提交购物车信息 生成会员订单
            Route::get('/mem_order_detail','OrderController@memOrderDetail');// 会员订单详情
            Route::post('/cancel_mem_order','OrderController@cancelMemOrder');// 取消会员订单
            Route::post('/accepter_mem_order','OrderController@accepterMemOrder');// 会员订单收货
            Route::post('/get_exp','OrderController@getExp');// 仅计算邮费
            Route::post('/choose_address','OrderController@chooseAddress');// 更新订单 - 地址信息
            Route::post('/choose_express_type','OrderController@chooseExpressType');// 更新订单 - 发货方式
            Route::post('/use_jf','OrderController@useJf');// 更新订单 - 积分   
            Route::post('/check_mem_pay','OrderController@checkMemPay');// 会员订单支付
            Route::get('/list','OrderController@getList');// 会员订单列表
        });
        Route::group(['prefix' => 'address'], function(){
            Route::get('/lists','AddressController@getAddressLists');// 地址列表
            Route::post('/change','AddressController@insertAddress');// 新增编辑地址
            Route::post('/del','AddressController@delAddress');// 删除地址
        });
        Route::group(['prefix' => 'withdraw'], function(){
            Route::get('/lists','WithdrawController@lists');// 提现记录列表
            Route::get('/withdraw_page','WithdrawController@withdrawPage');// 提现界面 - 传递 银行卡ID, 不传递则以默认ID为准, 如无默认iD, 返回 id=0
            Route::post('/withdraw','WithdrawController@withdraw');// 提现 - 传递 银行卡iD 和 提现金额(元)

            Route::get('/bank_lists','WithdrawController@bankLists');// 提现银行卡列表 - 返回null
            Route::post('/add_bank','WithdrawController@addBank');// 添加银行卡 - 银行卡数据
            Route::post('/edit_bank','WithdrawController@editBank');// 编辑银行卡 - 银行卡数据
            Route::post('/del_bank','WithdrawController@delBank');// 删除银行卡 - 银行卡ID
        });

        Route::group(['prefix' => 'grade'], function(){
            Route::get('/page','GradeController@gradePage');// 身份界面
        });

        Route::group(['prefix' => 'deal'], function(){
            Route::get('/list','DealController@getList'); // 交易记录
            Route::post('/transfer','DealController@transfer');// 转账
        });

        Route::group(['prefix' => 'banner'], function(){
            Route::get('/mem/list','BannerController@getList');
        });

        Route::group(['prefix' => 'notice'], function(){
            Route::get('/mem/list','NoticeController@getList');
            Route::get('/mem/detail','NoticeController@getDetail');
            Route::get('/mem/alert','NoticeController@getAlertNotice');
            Route::post('/record','NoticeController@saveRecord');
        });

        Route::group(['prefix' => 'pay'], function(){
            Route::post('order','PayController@initOrder');
            Route::post('ybprepay','PayController@ybPrePay');//易宝聚合支付-微信支付
            Route::post('trade_order','PayController@tradeOrder');//易宝银行卡快捷支付
        });
    });

});
